<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title>工作台</title>
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="./public/css/vendor/bootstrap/dist/bootstrap.css">
    <link rel="stylesheet" href="./public/css/vendor/Animate.css">
    <link rel="stylesheet" href="./public/css/basic.css">
    <link rel="stylesheet" href="./public/css/vendor/font_awesome/css/font-awesome.css">
    <!--[if lt IE 9]>
    <script src="./public/js/vendor/html5shiv.min.js"></script>
    <script src="./public/js/vendor/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="container">
    <form class="form-signin" method="post" action="http://localhost:8081/login/do">
        <h3>欢迎使用海上鲜</h3>
        <div class="form-group">
            <!--[if lte IE 9]><label>用户名</label><![endif]-->
            <input type="text" name="username" class="form-control" placeholder="用户名" autofocus="autofocus">
        </div>
        <div class="form-group">
            <!--[if lte IE 9]><label>密码</label><![endif]-->
            <input type="password" name="password" class="form-control" placeholder="密码" >
        </div>
        <div class="form-group" style="position:relative;">
            <!--[if lte IE 9]><label>验证码</label><![endif]-->
            <!--[if lte IE 9]><style type="text/css">.J_verify_code{top:33px !important;}</style><![endif]-->
            <input type="password" class="form-control" placeholder="验证码" >
            <div class="J_verify_code" style="cursor:pointer;position:absolute;top:8px;right:6px;">
                <img src="./public/images/code.png"/>
            </div>
        </div>
        <button class="btn btn-lg btn-primary btn-block subBtn" type="button" id="submitBtn">登录</button><p id="alermsg" style="color: red;"></p>
    </form>
</div>

<script src="./public/js/vendor/jquery.min.js"></script>
<script src="./public/js/vendor/bootstrap/dist/bootstrap.js"></script>
<script src="./public/js/vendor/ie10-viewport-bug-workaround.js"></script>

<script>

    $("#submitBtn").click(function () {

        var username=$.trim($("input[name='username']").val());
        var password=$.trim($("input[name='password']").val());
        if(""==username || ""==password){
            alert("请输入账号与密码");
            return;
        }
//        '{"username":'+username+','+'"password":'+password+'}',
        $.ajax({
            type: 'post',
            url: 'http://localhost:8081/login/do',
            contentType : 'application/json;charset=UTF-8',
            cache: false,
            data: '{"username":"'+username+'","password":"'+password+'"}',
            dataType: 'json',
            beforeSend: function () {
            },
            success: function (returnData) {
                var obj=returnData;
                if(obj.state=="success"){
                    window.location.href="./tpl/"
                }else{
                    alert(obj.message);
                }
            },
            error: function () {
                alert("未找到模板");
            }
        });

    });

</script>

</body>
</html>